// pages/index/moreProperty/moreProperty.js
import { API_HOST } from "../../../utils/const"
import http from "../../../utils/http"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    host: API_HOST,
    cid: '',
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('====options.id:', options.preId);
    this.setData({
      cid: options.preId
    });
    this.setData({
      list: [
        {
          'type': '办公用房',
          'area': 28,
          'address': '普陀区镇坪路280号'
        },
        {
          'type': '住宅用房',
          'area': 34,
          'address': '普陀区镇坪路280号普陀区镇坪路280号'
        },
        {
          'type': '商业用房',
          'area': 48,
          'address': '杨浦区武东路280号'
        },
        {
          'type': '工业用房',
          'area': 110,
          'address': '普陀区镇坪路280号'
        },
        {
          'type': '办公用房',
          'area': 52,
          'address': '普陀区镇坪路280号'
        },
        {
          'type': '住宅用房',
          'area': 70,
          'address': '普陀区镇坪路280号'
        },
        {
          'type': '商业用房',
          'area': 65,
          'address': '普陀区镇坪路280号'
        }
      ]
    });
    this.getPropertyList(options.preId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onShow: function () {
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  },

  test: function(){
    var that = this;
    http({
      url: "",
      data: {

      },
      success: function (res) {
        if (!res) return;
        that.setData({
          datas: res
        })
      }
    })
  },
  getPropertyList: function (cid) {
    var that = this;
    http({
      url: "/house/queryHouseList/v1.0.0",
      data: {
        processId: cid,
        pageNum: 1,
        pageSize: 10
      },
      method: 'POST',
      success: function (res) {
        console.log('list res:', res.data.rowItemList);
        if (!res) return;
        that.setData({
          list: res.data.rowItemList
        })
      },
      fail: function (res) {
        console.log('fail:', res);
      }
    })
  }
})